import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { svgBuilder } from "./src/plugins/svgBuilder";

// https://vitejs.dev/config/
export default ({ mode }) => {
  return defineConfig({
    plugins: [
      vue(),
      //引入SVG图标素材文件
      svgBuilder("./src/assets/icons/"),
    ],
    //启动服务配置
    server: {
      // https: false,
      proxy: {
        ["/api"]: {
          target: `http://10.11.1.186:8080`,
          changeOrigin: true,
          ws: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
      },
    },
    base: mode === "prod" ? "https://img2.xfb315.com/vue/new/admin" : "/",
    resolve: {
      //设置路径别名
      alias: {
        "@": path.resolve(__dirname, "./src"),
        "*": path.resolve(""),
      },
    },
  });
};
